package com.role.controller;

import com.microservice.entity.Role;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


import com.role.serivce.RoleService;

import io.swagger.annotations.ApiOperation;

import java.util.List;

@RestController
public class RoleController {

	@Autowired
	private RoleService roleService;
	
	@ApiOperation(value = "通过ID获取role")
	@GetMapping(value = "/get/{id}")
	public Role getRoleById(@PathVariable("id") Integer id) {
		return roleService.getRoleById(id);
	}


	@ApiOperation(value = "通过用户ID获取角色列表")
	@GetMapping(value = "/list/byUser/{userId}")
	public List<Role> getRolesByUserId(@PathVariable Integer userId){
		return roleService.getRolesByUserId(userId);
	}



	@ApiOperation(value = "保存")
	@PostMapping(value = "/save")
	public int saveRole(){
		return roleService.save();
	}

	
}
